package com.kexun.config.system;

import com.kexun.config.resolver.LoginUserHandlerMethodArgumentResolver;
import com.kexun.service.ManageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.List;

@Component
public class WebMvcConfig implements WebMvcConfigurer {

    @Autowired
    private ManageService userService;


    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
//        registry.addViewController("/").setViewName("index");
//        registry.addViewController("indexold.html").setViewName("index");
        registry.addViewController("noLogin").setViewName("noLogin");
    }

    //注册登录用户转换器 实现自动注入
    @Override
    public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers) {
        resolvers.add(new LoginUserHandlerMethodArgumentResolver(userService));
    }
}
